[[ package gen;

import se.rupy.http.*;
import se.rupy.sprout.*;

import com.maxmind.geoip.*;

public class user extends Sprout {
	public int index() { return 2; }
	public String path() { return "/user:/register"; }
	public void filter(Event event) throws Event, Exception {
		Output out = event.output();
		String country = event.string("country");
		
		if(country.length() == 0) {
			country = User.lookup.getCountry(event.remote()).getCode();
		}
		
		if(country.equals("--")) {
			country = "";
		}

		event.daemon().chain(event, "/header").filter(event); ]]

  <table border="0">
    <form name="user" action="[[ event.query().path() ]]" method="post">

[[		if(event.string("error").length() > 0) { ]]

      <tr>
        <td colspan="5">
          <font color="red"><i>[[ event.string("error") ]]</i></font>
        </td>
      </tr>

[[		} ]]

      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#F88017") ]]">[[ i18n("eMail") ]]</font>&nbsp;&nbsp;</td>
        <td colspan="3">
          <input type="text" class="mail" name="mail" value="[[ event.string("mail") ]]" style="text-transform: lowercase;" tabindex="1"/>
          <input type="checkbox" title="[[ i18n("Show eMail?") ]]" name="show_mail"[[ event.string("show_mail").equals("on") ? " checked" : "" ]]/>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#F88017") ]]">[[ i18n("Birthday") ]]</font>&nbsp;&nbsp;</td>
        <td colspan="3">
          <!-- // ISO 8601 -->
          <select name="year" class="year" tabindex="2">
            
[[		for(int i = 1900; i < 2009; i++) { ]]

            <option value="[[ i ]]"[[ event.query().medium("year", 1990) == i ? " selected" : "" ]]>[[ i ]]</option>

[[		} ]]

          </select>
          <select name="month" class="month" tabindex="3">
            
[[		for(int i = 1; i < 13; i++) { ]]

            <option value="[[ i ]]"[[ event.medium("month") == i ? " selected" : "" ]]>[[ i18n(User.month[i - 1]) ]]</option>

[[		} ]]

          </select>
          <select name="day" class="day" tabindex="4">
            
[[		for(int i = 1; i < 32; i++) { ]]

            <option value="[[ i ]]"[[ event.medium("day") == i ? " selected" : "" ]]>[[ i ]]</option>

[[		} ]]

          </select>
          <input type="checkbox" title="[[ i18n("Show birthday?") ]]" name="show_birthday"[[ event.string("show_birthday").equals("on") ? " checked" : "" ]]/>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#F88017") ]]">[[ i18n("Nickname") ]]</font>&nbsp;&nbsp;</td>
        <td colspan="2">
          <input id="name" type="text" class="small" name="name" value="[[ event.string("name") ]]" style="text-transform: lowercase;" onblur="ajaxNick(); return false;" tabindex="5"/>
        </td>
        <td rowspan="3" width="100">
          <table>
            <tr>
              <td>
                <img src="res/female.png" alt="[[ i18n("Female") ]]"/>
              </td>
              <td>
                <img src="res/male.png" alt="[[ i18n("Male") ]]"/>
              </td>
              <!--td>
                <input type="checkbox" name="show_gender"[[ event.string("show_gender").equals("on") ? " checked" : "" ]]/>
              </td-->
            </tr>
            <tr>
              <td align="center">
                <input type="radio" title="[[ i18n("Female") ]]" name="gender" value="female" [[ event.string("gender").equals("female") ? " checked" : "" ]]/>
              </td>
              <td align="center">
                <input type="radio" title="[[ i18n("Male") ]]" name="gender" value="male" [[ event.string("gender").equals("male") ? " checked" : "" ]]/>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#F88017") ]]">[[ i18n("Password") ]]</font>&nbsp;&nbsp;</td>
        <td colspan="2">
          <input type="password" class="small" name="pass" value="[[ event.string("pass") ]]" tabindex="6"/>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#F88017") ]]">[[ i18n("Confirm") ]]</font>&nbsp;&nbsp;</td>
        <td colspan="2">
          <input type="password" class="small" name="word" value="[[ event.string("word") ]]" onkeypress="return myKeyPressed(event)" tabindex="7"/>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#3B9C9C") ]]">[[ i18n("Country") ]]</font>&nbsp;&nbsp;</td>
        <td>
          <img id="flag" src="res/[[ out.print(country.length() > 0 ? "flag/" + country.toLowerCase() + ".png" : "pixel.gif"); ]]" align="right" style="vertical-align: middle;[[ out.print(country.length() == 0 ? " display: none;" : ""); ]]"/>
        </td>
        <td align="right">
          <select name="country" class="country" onChange="changeFlag(this);" tabindex="8">
            <option value="--">N/A</option>
            
[[		for(int i = 0; i < User.countryCode.length; i++) { ]]

            <option value="[[ User.countryCode[i] ]]"[[ country.equals(User.countryCode[i]) ? " selected" : "" ]]>[[ User.countryName[i] ]]</option>

[[		} ]]

          </select>
        </td>
        <td>
          <input type="checkbox" title="[[ i18n("Show country?") ]]" name="show_country"[[ event.string("show_country").equals("on") ? " checked" : "" ]]/>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#3B9C9C") ]]">[[ out.print(i18n("First&nbsp;Name")); ]]</font>&nbsp;&nbsp;</td>
        <td colspan="2">
          <input type="text" class="small" name="first" value="[[ event.string("first") ]]" tabindex="9"/>
        </td>
        <td>
          <input type="checkbox" title="[[ i18n("Show first name?") ]]" name="show_first_name"[[ event.string("show_first_name").equals("on") ? " checked" : "" ]]/>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"><font color="[[ i18n("#3B9C9C") ]]">[[ out.print(i18n("Last&nbsp;Name")); ]]</font>&nbsp;&nbsp;</td>
        <td colspan="2">
          <input type="text" class="small" name="last" value="[[ event.string("last") ]]" tabindex="10"/>
        </td>
        <td>
          <input type="checkbox" title="[[ i18n("Show last name?") ]]" name="show_last_name"[[ event.string("show_last_name").equals("on") ? " checked" : "" ]]/>
        </td>
      </tr>
      <input type="hidden" name="picture" value="[[ out.print(event.string("picture").length() > 0 ? event.string("picture") : ""); ]]">
    </form>
    <form enctype="multipart/form-data" name="upload" action="picture" target="frame" method="post">
      <tr>
        <td colspan="4">
          <a class="button overflow">
            <input name="file" type="file" class="file" style="left: 5px;" tabindex="-1" onchange="document.upload.submit()"/>
            <span>[[ out.println(i18n("Profile&nbsp;Picture")); ]]</span>
          </a>
        </td>
        <td rowspan="2" valign="middle">
          <img name="picture" width="50" height="50" src="[[ out.print(event.string("picture").length() > 0 ? event.string("picture") : "res/pixel.gif"); ]]">
        </td>
      </tr>
    </form>
    <tr>
      <td colspan="4">
        <a href="" class="arrow" onclick="document.user.submit(); return false;">
          <span>[[ event.query().path().equals("/user") ? i18n("Save") : i18n("Create") ]]</span>
        </a>
      </td>
    </tr>
  </table>
</div>

<iframe name="frame" style="width: 0; height: 0; border: 0px;"></iframe>

</body>
</html>

[[ } 
} ]]

